extends CharacterBody2D
class_name Plyaer
@export var speed :=100
@onready var graphic:Node2D = $Graphic

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.

func  move() -> void:
	var direction :=Input.get_vector("move_left","move_right","move_up","move_down")
	if direction != Vector2.ZERO:
		velocity = direction * speed
		move_and_slide()	
	else:
		velocity = Vector2.ZERO
	if not is_zero_approx(direction.x):
		graphic.scale.x = 1 if direction.x >0 else -1	
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta: float) -> void:
	move()
	pass
